
from rest_framework import serializers

from cart.models import BorrowCart


class BorrowSer(serializers.ModelSerializer):
    borrowlist=serializers.SerializerMethodField(read_only=True)
    def get_borrowlist(self,obj):
        return {'name':obj.book.name,'type':obj.book.type.name,'price':obj.book.price,'img':obj.book.img,'auther':obj.book.auther,'house':obj.book.house.name,'time':obj.book.time,'id':obj.book.id}
    class Meta:
        model = BorrowCart
        fields = '__all__'